//This method will do the request to server to get the players who is already in the DB
$(document).ready(function () {
    $.ajax({
        type:'GET',
        url:"/jowey/timeReport/getTimeReports",
        dataType:'json',
        success:function (result) {
        	
        	var table = $('#timeReportTable');
        	var line;
        	var tdMonth;
        	var tdWeeks; 		   
        	var tdStatus;  
        	var tdLinkOpen;
        	var open = "../timeReport/open";
        	
        	for(var i = 0;i<result.length;i++){
  
        		line		   = document.createElement("tr");
        		tdMonth 	   = document.createElement("td");
            	tdWeeks        = document.createElement("td");
            	tdStatus	   = document.createElement("td");
            	tdLinkOpen     = document.createElement("td");
            	
            	
            	tdMonth.innerHTML  	 = result[i].month;
            	tdWeeks.innerHTML  	 = result[i].weekFrom + "-" + result[i].weekTo;
            	tdStatus.innerHTML 	 = result[i].status;
            	tdLinkOpen.innerHTML = "<a href="+open+">OPEN</a>";
            	
            	line.appendChild(tdMonth);
            	line.appendChild(tdWeeks);
            	line.appendChild(tdStatus);
            	line.appendChild(tdLinkOpen);
            	
            	table.append(line);
        	}
        },
        error:function (jqXHR, textStatus, errorThrown) {
            alert("player " + textStatus + " " + errorThrown + " !");
        }
    });
});
